Skip to content

rtorras/jQuery-Ajax-Latency-Simulator-Plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

jQuery AJAX Latency Simulator Plugin

This is a jQuery plugin that simulates HTTP latency when requesting resources using jQuery.ajax. This plugin affect all jQuery functions related to AJAX since all of these functions internally use jQuery.ajax.

This plugin it is not designed for production use. Instead it was developed to simulate latency when developing a jQuery web application locally, where resources that are requested via AJAX are delivery too fast.

How to use it?

It should be simple, and it is. It takes one line after including jQuery and the plugin (of course!).

<html>
  <head>
    <script type="text/javascript" src="/path/to/jquery.js"></script>
    <script type="text/javascript" src="/path/to/jquery.ajax.latency.simulator.js"></script>
    <script type="text/javascript">
      jQuery(function($) {
        // All AJAX request will be delayed by 5000 ms.
        $.fn.ajaxLatencySimulator({delay : 5000});
      });
    </script>
  </head>
</html>

I told you that is just that simple.

Any options (aka documentation)?

You can configure the behaviour of the latency. It could be linear (as in the previous example) or variable. The following snippet shows you how to get a linear or a variable latency.

// I would like a linear latency of 3.5 seconds.
$.fn.ajaxLatencySimulator({delay : 3500});

// I would like a variable latency from 2 seconds to 6 seconds.
$.fn.ajaxLatencySimulator({min : 2000, max : 6000});

And that's all.

About

A jQuery plugin that simulate latency for any AJAX request via jQuery plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published