Click here to Skip to main content
12,449,762 members (78,328 online)
Click here to Skip to main content
Articles » Web Development » Ajax » Libraries » Downloads


91 bookmarked

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

, 9 Jun 2008 CPOL
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

You may also be interested in...

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