Skip to content

Instantly share code, notes, and snippets.

@docluv
Forked from simonhearne/SPA.js
Created September 24, 2016 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docluv/79770c33702abba325a3d097f0e6cf08 to your computer and use it in GitHub Desktop.
Save docluv/79770c33702abba325a3d097f0e6cf08 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