Combining Javascript Files to Reduce HTTP Requests

Posted by:

I just wanted a very basic PHP script to combine all my JS files into one – no minification, just bring them together into one file.

<?php
// compress the file using GZIP
ob_start("ob_gzhandler"); 

// javascript content-type
header('Content-type: text/javascript');

// define the files you want to combine
$files = array('jquery.js', 'app.js', 'somePlugin.js');

// combine the files
foreach($files as $file) {
    // get the contents of this file
    $content .= file_get_contents($file) . '
'; //add a new line
}

// output the contents
echo $content;

?>
Continue Reading →
0

Resizing High Resolution (Hi-res) JPEG Images with PHP

Posted by:

I kept running into a problem when I uploaded high resolution (14MP) images and tried creating thumbnails with them. The issue turned out being the PHP script ran out of memory. So it was a simple increase to about a half gig (512MB) and the script ran perfectly. Here’s the code:

thumbnail.php?src=myImage.jpg&w=300

<?php
ini_set ( "memory_limit", "512M");
header('Content-Type:image/jpeg');
echo createThumb($_GET["src"],$_GET["w"]);


function createThumb( $path, $thumbWidth ) 
{
 
    $info = pathinfo($path);
    // continue only if this is a JPEG ...
Continue Reading →
0

New Twitter API (v1.1) Quick Start

Posted by:

This tutorial will help you get started with the new Twitter API which will be much different than the deprecated 1.0 version. In this example we’ll look at how to get a user’s timeline via the API.

  1. Setup your developer account if you haven’t done so yet at https://dev.twitter.com
  2. Go to https://apps.twitter.com/ and create your app
  3. Once created click on the Keys and Access Tokens tab and Create Access Tokens (for this example we only need Read access but for ...
Continue Reading →
0
Page 1 of 11 12345...»