Lazy Loading swfobject.js

The SWFObject.js file can be lazy loaded.

Google's google.load

If you intend to use Google's cached copy of SWFObject (highly recommended), you can also take advantage of Google's lazy loading tool.

<script type="text/javascript" src=""></script>
<script type="text/javascript">
google.load("swfobject", "2.2");
google.setOnLoadCallback(function() {

Google's documentation can give you all the details, but the nitty-gritty is this:

  1. Load the jsapi file
  2. Specify which Google Ajax API file you want to load (in this case SWFObject version 2.2)
  3. Optional: Specify a function to execute when the SWFObject file has been successfully loaded in your page

Other lazy loading techniques

Frankly, there are too many lazy loading techniques to mention. Excluding the Google example posted above, none are specific to SWFObject, and will work with just about any script file. has a great overview of lazy loading.

Questions or Comments?

If you have questions or would like to point out an error, please post your remarks in the SWFObject Google Group. Thanks!