in Uncategorized

What I have learned today 2016.10.14

#1 A simple method to test if is touch device in JavaScript

And if you combine that with a simple screen width conditional it can become something useful.

Has anyone a better idea? Post it in the comments. I would love to hear it.

#2 Have you wondered what WordPress script localization does?

The cleanest method to pass variables from Php to JavaScript in WordPress is by using localization function.

Something like this used in your functions.php file:

In JavaScript you would call them like this:

The above technique simply works and it’s really useful but have you ever wondered what happens under the hood?

Behold!

Pfff, no magic here 🤔

Write a Comment

Comment