Client-side transformations allow you to remix a webpage after it has been delivered using JavaScript. Learn how to relayout a page and manage the loading of external resources all from the comfort of the client!
13. How should we implement layout control?
<html> <html>
<body> <body>
<h1>one</h1> <h2>two</h2>
<h2>two</h2> <h1>one</h1>
<body> <body>
</html> </html>
14. How should we implement layout control?
<html>
<body>
<h1>One</h1>
<h2>Two</h1>
<script type="text/javascript">
$('h2').before('h1');
</script>
</body>
</html>
15. How should we implement layout control?
<html>
<body>
<script type="text/javascript">
var $body = $('body').hide();
</script>
<h1>One</h1>
<h2>Two</h1>
<script type="text/javascript">
$(function() {
$('h2').before($('h1'));
$body.show();
});
</script>
</body>
</html>
16. How can we implement resource control?
<html>
<body>
<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>
</body>
</html>
17. How can we implement resource control?
<html>
<body>
<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>
<script type="text/javascript">
$('[src="one.js"]').before($('[src="two.js"]'));
</script>
</body>
</html>
18. How can we implement resource control?
<script type="text/javascript">
var $doc = $(document).bind('beforeload', function(e) {
e.preventDefault();
});
</script>
19. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
var scripts = [];
var $doc = $(document).bind('beforeload', function(e) {
scripts.push(e.target);
e.preventDefault();
});
$(function() {
$doc.unbind('beforeload');
(function loadScripts() {
var script = scripts.pop();
if (script) $.getScript(script.src, loadScripts);
})();
});
</script>
<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>
</body>
</html>
20. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
var scripts = [];
var $doc = $(document).bind('beforeload', function(e) {
scripts.push(e.target);
e.preventDefault();
});
$(function() {
$doc.unbind('beforeload');
(function loadScript() {
var script = scripts.pop();
if (script) $.getScript(script.src, loadScript);
})();
});
</script>
<script type="text/javascript" src="one.js"></script>
<script type="text/javascript" src="two.js"></script>
</body>
</html>
21. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
var scripts = [];
var $doc = $(document).bind('beforeload', function(e) {
scripts.push(e.target);
e.preventDefault();
});
$(function() {
$doc.unbind('beforeload');
(function loadScript() {
var script = scripts.pop();
if (script) $.getScript(script.src, loadScript);
})();
});
</script>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</body>
</html>
22. How can we implement resource control?
<script type="text/x-javascript">alert('one');</script>
23. How can we implement resource control?
<html>
<body>
<noscript>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</noscript>
</body>
</html>
24. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
document.write('x3Cnoscript>');
</script>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</noscript>
</body>
</html>
25. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
document.write('x3Cnoscript>');
</script>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</noscript>
</body>
</html>
26. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
document.write('x3Cnoscript>');
</script>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</noscript>
</body>
</html>
27. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
document.write('x3Cstyle type="text/x-css">');
</script>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</style>
</body>
</html>
28. How can we implement resource control?
<html>
<body>
<script type="text/javascript">
document.write('x3Cstyle type="text/x-css">');
</script>
<script type="text/javascript">alert('one');</script>
<script type="text/javascript">alert('two');</script>
</style>
<script type="text/javascript">
var $scripts = $($('style').html());
$scripts.reverse();
$('body').append($scripts);
</script>
</body>
</html>
The ability to transform the way a webpage is loaded by the client.\n
The ability to transform the way a webpage is loaded by the client.\n
SHOW ME\n
Totally remix the page.\nUse existing components - or don&#x2019;t\nHoney Badger - it just care. We don&#x2019;t care about your original HTML. (but we could if we wanted to)\n
\n
\n
\n
\n
\n
Why didn&#x2019;t you just do this in the beginning\n
\n
So we got this, how are we actually gonna make it work?\n
So we got this, how are we actually gonna make it work?\n
So we got this, how are we actually gonna make it work?\n
So we got this, how are we actually gonna make it work?\n
So we got this, how are we actually gonna make it work?\n