I’ve got some PHP that I don’t want loaded immediately.
Is it possible to do something like this?
<?php
// ... snip ...
?>
<div class="footer">
<other divs/>
<script type="text/javascript">
setTimeout( function() {
<?php include(CHILD_DIR . '/modules/partner-init.php'); ?>
}, 10000);
</script>
</div>
That seems a little sloppy, but before I jump in to it, I want to know if it’s either a) possible, or b) if there’s a better way
It’s not possible, the include would be placed right there. The PHP is executed on the server before it’s sent to the client for the JS to be executed.
Also, it wouldn’t hurt to just do it and see what happens, it will help you learn.
If you want PHP to be executed later, you could request the page in an AJAX request. This will make it so the PHP is executed from the request, which can be controlled/timed by JS.