Javascript work
* removed cache and remember from js task * renamed js variables * reworked js code * added logPerf function to page head
This commit is contained in:
parent
0fa1b3c4b4
commit
4cb89ec7af
8 changed files with 257 additions and 235 deletions
|
|
@ -10,6 +10,8 @@
|
|||
{% include "demo/partials/_meta.njk" %}
|
||||
{% block meta %}{% endblock %}
|
||||
|
||||
{% include "hippie/partials/_head_script.njk" %}
|
||||
|
||||
{% include "demo/partials/_links.njk" %}
|
||||
{% block links %}
|
||||
<link rel="stylesheet" type="text/css" media="all" href="/css/demo.css"/>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
{% include "demo/partials/_meta.njk" %}
|
||||
{% block meta %}{% endblock %}
|
||||
|
||||
{% include "hippie/partials/_head_script.njk" %}
|
||||
|
||||
{% include "demo/partials/_links.njk" %}
|
||||
{% block links %}
|
||||
<!--[if lte IE 9]>
|
||||
|
|
|
|||
32
source/templates/hippie/partials/_head_script.njk
Normal file
32
source/templates/hippie/partials/_head_script.njk
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<!-- head.script.partial -->
|
||||
<script>
|
||||
//Entry script at page init
|
||||
|
||||
// get the current time difference between page
|
||||
// load and when this func was invoked
|
||||
function getTimeDiff() {
|
||||
return new Date().getTime() - performance.timing.navigationStart;
|
||||
}
|
||||
|
||||
var debugOn = true;
|
||||
var $log, assetsLoaded = false;
|
||||
|
||||
function logPerf(msg) {
|
||||
if (debugOn) {
|
||||
if (assetsLoaded) {
|
||||
if (!$('#jslogPerf').length) {
|
||||
$('body').prepend('<div id="jslogPerf" style="position:fixed;bottom:8px;right:16px;z-index:1000;padding:8px;background:rgb(0,255,255,.5)"></div>')
|
||||
}
|
||||
$log = $log || $('#jslogPerf');
|
||||
$log.append('<p style="margin-bottom:4px;font-size:.75em;"><b>' + getTimeDiff() + '</b>ms :: ' + msg);
|
||||
}
|
||||
if (window.console) {
|
||||
console.log(getTimeDiff() + 'ms :: ' + msg);
|
||||
if (console.timeStamp){
|
||||
console.timeStamp(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
logPerf('On HEAD, starting...');
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue