Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
/ loadScript Public archive

[DEPRECATED] Small JS script loader utility; allows client-side script substitution.

License

Notifications You must be signed in to change notification settings

zynga/loadScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please note: This project is deprecated at Zynga and is no longer maintained.


Overview

loadScript() is a global function for performing asynchronous script loads.

Run unit tests.

Features

  • Tiny! (1kB minified)
  • Supports .noConflict()
  • For developers, allows you to rewrite script URLs based on localStorage string substitution rules, making it easy to develop a new version of your JS products, even working off of a production site!

How does that work, exactly?

Include loadScript.js via a script tag:

	<script src="loadScript.js" type="text/javascript"></script>

If you want to make use of the URL substitution feature, do this:

	loadScript.key = 'my_localStorage_key';

Actually loading a script is easy:

	var jqURL = '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js';
	loadScript(jsURL, function () {
		// jQuery is now loaded!
	});

Now if you, as a developer, want to test out your production site with the non-minified jQuery source for debugging purposes, just use the browser's dev tools to set a localStorage value:

	localStorage.setItem('my_localStorage_key', '[[".min",""]]');

Now when you refresh the page, loadScript() will perform a string substitution on your URLs to remove the '.min' substring. This will only affect you, not other users of the site.

The localStorage value must be a valid JSON stringified array of arrays, where each inner array has exactly two elements: [<searchtext>,<replacetext>]

About

[DEPRECATED] Small JS script loader utility; allows client-side script substitution.

Resources

License

Stars

Watchers

Forks

Packages

No packages published