Skip to content

Instantly share code, notes, and snippets.

@rgranadino
Forked from colinmollenhour/tags.php
Last active August 29, 2015 13:56
Show Gist options
  • Save rgranadino/9302694 to your computer and use it in GitHub Desktop.
Save rgranadino/9302694 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head><title>Script Block Test</title></head>
<body>
<?php if (isset($_GET['mode']) && $_GET['mode'] == 'inline'): ?>
<script type="text/javascript">
var domReadyQueue = [];
var x=function(){return {on: function(){}};};
</script>
<?php for($i = 0; $i < 100; $i++): ?>
<h4><?php echo $i ?></h4>
<img src='http://lorempixel.com/400/200/?t=<?php echo time()+$i;?>'>
<script type="text/javascript">
domReadyQueue.push(function(){ x('#someId').on('click', function(){}); });
</script>
<?php endfor ?>
<script type="text/javascript">
while(domReadyQueue.length) {
(domReadyQueue.shift())();
}
</script>
<?php else: ?>
<?php for($i = 0; $i < 100; $i++): ?>
<h4><?php echo $i ?></h4>
<img src='http://lorempixel.com/400/200/?t=<?php echo time()+$i;?>'>
<?php endfor ?>
<script type="text/javascript">
var x=function(){return {on: function(){}};};
<?php for($i = 0; $i < 100; $i++): ?>
(function(){ x('#someId').on('click', function(){}); })();
<?php endfor ?>
</script>
<?php endif ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment