Skip to content

Instantly share code, notes, and snippets.

@simonhearne
Last active November 25, 2016 02:01
Show Gist options
  • Save simonhearne/852eff2bd35bb0e15a836a59b9678e37 to your computer and use it in GitHub Desktop.
Save simonhearne/852eff2bd35bb0e15a836a59b9678e37 to your computer and use it in GitHub Desktop.
Custom metric for WebPageTest to detect single page application frameworks
var SPA="none";
if (typeof(app)=="object") SPA = "unknown";
if (window.hasOwnProperty('require')) {
if(window.require.hasOwnProperty('defined')){
if(window.require.defined('troopjs-compose/decorator')) SPA = "troop";
if(window.require.defined('flight/lib/component')) SPA = "flight";
}
}
if (typeof(window.Polymer)=="function") SPA = "polymer";
if (typeof(window.React)=="object") SPA = "react";
if (typeof(window.Vue)=="function") SPA = "vue";
if (typeof(window.aureliaDatabase)=="object") SPA = "aurelia";
if (typeof(window.angular)=="object") SPA = "angular";
if (typeof(window.ko)=="object") SPA = "knockout";
if (typeof(window.Backbone)=="object") SPA = "backbone";
if (typeof(window.ko)=="object" && typeof(window.Backbone)=="object") SPA = "knockback";
if (typeof(window.dojo)=="object") SPA = "dojo";
if (typeof(window.can)=="object") SPA = "can";
if (typeof(window.ampersand)=="object") SPA = "ampersand";
if (window.hasOwnProperty('m')) {
if (window.m.hasOwnProperty('render')) {
if (typeof(window.m.render)=="function") SPA = "mithril";
}
}
return SPA;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment