Most recent enhancements in the “Ajaxify” plugin

Views: 1050

New features of Ajaxify plugin

The latest version of Ajaxify, has new and exciting features:

Only the most important are highlighted here:

  • Greatly accelerated page loads
  • Option “inline” to steer whether all inline scripts should be re-fired
  • Class “ajaxy” to specify inline scripts that should be re-fired each time
  • Option “inlinehints” to specify inline scripts that should be re-fired each time
  • Minimized number of initial GET requests
  • Pronto variant and main file now fusioned into one sleak minified JS

Please drop us a comment what you think!

Views: 5115

getScripts

When developing the latest version of this plugin, I decided to craft this new jQuery plugin – getScripts:

You can load multiple external JavaScript files dynamically that can depend on each other!

The callback function is called only once…

Usage

$myScripts.getScripts(callback);
// The getScripts plugin
(function ($) {
// The Scripts class
var Scripts = function() {
    this.a = function($this, cb) { var s = '';
        if($this.length == 0) { cb && cb(); return; }
        $this.each(function(i){
            s += 'addsrc* = function() { $.getScript("*", *).fail(function(jqxhr, settings, exception) {alert(exception);}); }'.replace('*', i)
                .replace('*', $(this).attr('src'))
                .replace('*', i == $this.length - 1 ? 'cb' : 'addsrc' + (i + 1));
            s += i == $this.length - 1 ? ';' : ',';
        });
         
        s = 'var ' + s + '\n' + 'addsrc0();';
         
        try { eval(s); } catch(e) {alert(e);};
    };
}; //end Scripts class
  
// Register jQuery function
$.fn.getScripts = function(cb) {
    var $this = $(this);
    $.fn.getScripts.o = $.fn.getScripts.o ? $.fn.getScripts.o : new Scripts();
    $.fn.getScripts.o.a($this, cb);
    return $this;
};

Views: 3224

Copyright 2005-2015, 4nf.org. All rights reserved.
Last update of site: 5. September 2015
View statistics since 1. November 2013