Skip to content

Instantly share code, notes, and snippets.

Avatar

Tamim Bin Ibrahim tamimibrahim

View GitHub Profile
@tamimibrahim
tamimibrahim / file1.txt
Created November 18, 2017 13:12
Test gist using api
View file1.txt
Cool gist , working or not ?
@tamimibrahim
tamimibrahim / file1.txt
Created November 18, 2017 13:06
Test gist using api
View file1.txt
Cool gist , working or not ?
@tamimibrahim
tamimibrahim / noncritcss.md
Created October 18, 2015 10:29 — forked from scottjehl/noncritcss.md
Comparing two ways to load non-critical CSS
View noncritcss.md

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/


For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

View screenshots.js
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
View gist:dc5d70d06cc6cc1714d5
var page = require('webpage').create();
page.settings.loadImages = false;
page.onConsoleMessage = function(msg) { console.log(msg); };
var pageUrl = 'http://www.bloggersentral.com/2010/08/how-put-add-adsense-on-blogger.html';
var num = 0;
var max = 2;
page.onLoadFinished = function() {
var text = page.evaluate(function() {
View fake-referrer.phantom.js
var system = require('system');
// Exit in case of wrong parameter count.
if (system.args.length !== 3) {
console.log('Usage: scriptname targetUrl referrer');
console.log('example: $> phantomjs fake-referrer.phantom.js http://example.com http://referrer.example.com');
phantom.exit();
}
// Set the important pieces
View t5-silent-flush.php
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Silent Flush
* Description: Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
* Version: 2013.05.04
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
View SmoothScroll.js
// SmoothScroll for websites v1.2.1
// Licensed under the terms of the MIT license.
// People involved
// - Balazs Galambosi (maintainer)
// - Michael Herf (Pulse Algorithm)
(function(){
// Scroll Variables (tweakable)
View color-gen.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
var colortest = $("#colortest");
for (i = 1; i <= 300; i++) {
var c = genColor();
var newhtml = "<span style='font-family:\"Courier\",monospace;width:50px;height:30px;background-color:#" + c + "'>#" + c + "</span>";
colortest.html(colortest.html() + newhtml);