Click here to Skip to main content
12,998,785 members (70,748 online)
Click here to Skip to main content
Articles » Web Development » Ajax » Libraries » Downloads

Stats

112.7K views
584 downloads
91 bookmarked
Posted 9 Jun 2008

ensure - Ensure JavaScripts/HTML/CSS are loaded on-demand when needed

, 9 Jun 2008
A tiny JavaScript library that provides a handy function "ensure" which allows you to load JavaScript, HTML, CSS on-demand and then execute your code. ensure ensures that relevant JavaScript and HTML snippets are already in the browser DOM before executing your code that uses them.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Popup.aspx.cs" Inherits="Components_Popup" %>

<div class="popup" style="display:none" id="Popup">
    <h1>This is a popup</h1>
    <p>As you see <em>ensure</em> loaded two snippet sets where one is for the fade effect in the background and another is for the popup box.</p>
    <p>The fade effect uses BlockUI.html, BlockUI.js</p>
    <p>The popup uses Popup.aspx and Popup.css</p>
    <p>
    <input type="button" value="Close" onclick="ensure({js:'Components/BlockUI.js'}, function(){ BlockUI.hide(); document.getElementById('Popup').style.display='none'})" />
    </p>
</div>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 9 Jun 2008
Article Copyright 2008 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid