The beautiful function wp_localize_script() was built for l11n, however its found as a method for carrying over server-side values into client-side JS. Your values are now available in your .js file: Currently using this in a React theme I’m building for WordPress. This can also be done with something like:
This little function allows a form to have reCAPTCHA hidden until a user begins entering form values.
The following script stores the first result from Google Maps v3 API AutoComplete into a hidden input, allowing you to do something with the autocomplete input field if the user decides to type their address instead of click a result. I’ve included only the extra code ontop of the normal autoComplete script.
Another incredible snippet if you’ve got a JS app that changes images and want said images to be ready and loaded, but not overwhelm the normal page load.
Probably one of the better scripts to keep in your snippet drawer. & it’s so simple.
Say you have an element #banner with a background-image. On a responsive design that’s width:100%; you’ll notice your image will be auto croped by the viewport change. The solution is simple: background-size: cover; but a pain that follows is the height of the element will not scale down or up with the width change, leaving […]
UPDATE: Please note this post is from 2012. Every since the tablet boom in the last two or so years, responsive design is the only way to make sites. As an owner of a tablet and heavy web user, it makes a world of difference on my impression of a site (and thus a company/organization) […]