Based on your description that you “created a front-page.php
and added the following” and also that there is markup in that file, you are hooking too late.
You should be both registering and enqueueing on wp_enqueue_scripts
but that isn’t the problem here. The problem is that by the time you try to hook, the hooks have already fired. init
will fire before your templates load at all and wp_enqueue_scripts
will fire in the page header, which is before this code runs (or you have very broken markup). You can’t hook
to a hook after it has fired.
You need to add this code to the theme’s functions.php
with the appropriate template tags to conditionally load the scripts.