-
Notifications
You must be signed in to change notification settings - Fork 0
yslow framework
Welcome to the yslow-framework wiki!
Yslow Framework is a service to analyse performance of a webpage. It uses yslow.js to generate report and we use phantomjs to run yslow.js. Phantomjs is an headless browser to run javascript using console.
Script is made with following assumptions
- Script is used inside IIIT network. Therefore, environment variables http_proxy and https_proxy are assigned http://proxy.iiit.ac.in and https://proxy.iiit.ac.in respectively. Please comment out following lines if you are not using any proxy else set proxy variables according to your network proxy. export http_proxy=”http://proxy.iiit.ac.in:8080” echo “Your proxy $http_proxy” export https_proxy=”https://proxy.iiit.ac.in:8080” echo “Your https proxy is $https_proxy”
- Script should be run by user with root access.
- Script is tested successfully on a container with ubuntu-12.04-custom-x86_64 ostemplate.
Sources of yslow-framework are available in following folders htdocs and autodeployment-script. Folder autodeployment-scripts contains shell script named yslow-framewok-spec.sh. To run this script use following command “sh yslow-framework-spec.sh” from inside shell environment. This script was made for deploying yslow framework using OVPL on the container of openVZ.
- Xamp server stack
- nodejs for getting npm packages
- npm package for phantomjs
- Sources code located at yslow-framework/src
# /bin/bash
export http_proxy="http://proxy.iiit.ac.in:8080"
echo "Your proxy $http_proxy"
export https_proxy="https://proxy.iiit.ac.in:8080"
echo "Your https proxy is $https_proxy"
apt-get update
apt-get -y install php5 apache2
apt-get purge nodejs npm
apt-get install -y python-software-properties python g++ make software-properties-common
echo -ne '\n' | add-apt-repository ppa:chris-lea/node.js
apt-get -y update
apt-get install -y nodejs
#apt-get install -y npm
#apt-get upgrade -y npm nodejs
npm config set https-proxy http://proxy.iiit.ac.in:8080
npm config set proxy http://proxy.iiit.ac.in:8080
#apt-get install -y build-essential chrpath git-core libssl-dev libfontconfig1-dev libxft-dev
npm install phantomjs
cp node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/bin
wget http://downloads.sourceforge.net/project/xampp/XAMPP%20Linux/1.8.3/xampp-linux-x64-1.8.3-4-installer.run
chmod +x xampp-linux-x64-1.8.3-4-installer.run
yes | ./xampp-linux-x64-1.8.3-4-installer.run
service apache2 stop
/opt/lampp/lampp start
git clone https://github.com/vlead/yslow-framework.git
chmod -R 775 yslow-framework/
cd yslow-framework/src/
cp htdocs/* /opt/lampp/htdocs
Yslow framework has very simple architecture with simple html page on the front-end which requires user to enter any public url of a wepage and when user clicks on submit button, url string is passed as an argument to php script named index.php. This index.php invokes shell scripts named in.sh using same argument.
Below is code for index.html
<html>
<head>
</head>
<body>
<div>
<p><strong>Enter the URL to check its efficiency with a full report</strong></p>
<form action="index.php" method="post">
<input type="text" name="url" placeholder="Enter The URL"/><br><br>
<input type="submit" value="SUBMIT"/>
</form>
<p>PLEASE WAIT......</p>
<p>The script takes time to run</p>
</div>
</html>
Below is code index.php where ‘url’ is an argument submitted by user from the front end.
<?php
if($_POST['url'])
{
$URL=$_POST['url'];
echo $URL;
chdir('.');
$output=shell_exec("./in.sh $URL");
echo "<pre>$output</pre>";
}
?>
Below is source of script in.sh
#! /bin/bash
output=$(phantomjs yslow.js --info all --format plain --ua "MSIE 9.0" $1)
echo "$output"
exit
Shell scripts only interprets following command phantomjs yslow.js –info all –format plain –ua “MSIE 9.0” $1 where ‘$1’ implies url submitted by the user, [yslow.js](http://yslow.org/) analyzes web pages and why they are slow based on Yahoo!’s rules for high performance web sites and [PhantomJS](http://phantomjs.org/) is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.