Skip to content
This repository was archived by the owner on Apr 15, 2019. It is now read-only.

Prevent execute html content before boomerang.js finished #47

@Artemis909

Description

@Artemis909

situation is:

Javascript boomerang.js used as test of client net speed, problem is that html content is executed by browser and is not waiting for boomerang result. But boomerang result is needed because there are some changes in html content.

How it is possible to do not execute html content before boomernag.js has result?

   <!DOCTYPE html>
   <html lang="en">
   <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel='stylesheet' type='text/css' media='all' href='css/style.css' />
    <link rel='stylesheet' type='text/css' media='all' href='css/colorbox.css' />
    <script type="text/javascript" src="js/speedtest/boomerang.min.js"></script>
    <script>
      BOOMR.init({ beacon_url: "http://www.zzz.xx", user_ip: '10.0.0.1', site_domain: "http://www.zzz.xx", BW: { nruns: 3, base_url: 'http://www.zzz.xx/test_images/', cookie: 'SPEED-test'}});
      </script>
       <script type="text/javascript" src="js/preload.js"></script>

preload.js is just check cookies and if exist do not make test again, if does not, run speedtest by BOOMR.subscribe

          var version_set=getCookie("speedtest_version_set");

         if (version_set == "low"){

                                  $(document).ready(website_init_low);      

           } else if (version_set == "high"){

                                  $(document).ready(website_init_high);

                } else {


             BOOMR.subscribe('before_beacon', function(o) {  

              if(o.bw) {  
                          netspeed = Math.abs(parseInt(o.bw*8/1024)); 
               var netspeed_limit = 5000; 

          if (netspeed < netspeed_limit) { 

                     document.cookie="speedtest_version_set = low";
                     $(document).ready(website_init_low);

            } else {
                    document.cookie="speedtest_version_set = high";  
                    $(document).ready(website_init_high);


            }

   }
     });

           }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions