Click here to Skip to main content
11,504,472 members (73,845 online)
Click here to Skip to main content
Articles » Web Development » Ajax » Libraries » Downloads
Add your own
alternative version

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

, 9 Jun 2008 CPOL 97K 535 90
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>
    <input type="button" value="Close" onclick="ensure({js:'Components/BlockUI.js'}, function(){ BlockUI.hide(); document.getElementById('Popup').style.display='none'})" />

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.


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


About the Author

Omar Al Zabir
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

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