Software Engineering in WordPress, PHP, and Backend Development

Tag: JavaScript (Page 9 of 12)

Articles, tips, and resources for JavaScript-based development.

Unicode Characters, Regular Expressions, JavaScript, and WordPress

For those who have been into computer science for any amount of time, you’re likely familiar with Joel Spolsky, his blog Joel on Software, and/or perhaps any of his books.

A couple of years ago, I read an article called The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).

I’m not ashamed to admit that, at the time, it wasn’t very applicable to me. Yes, it was interesting, yes, I cared, but I didn’t have a practical way to implement it simply because there was nothing that I was working that warranted the information in the article.

But here was one of my biggest takeaways:

If you completely forget everything I just explained, please remember one extremely important fact. It does not make sense to have a string without knowing what encoding it uses. You can no longer stick your head in the sand and pretend that “plain” text is ASCII.

Fast forward a couple of years and I was working at a place where every piece of application code that we rolled out had to be internationalized because it was accessible by a variety of countries all across the world – now it was more practical (and it’s not much different than WordPress, huh?).

And now, I’m finding myself working more with unicode characters in WordPress more than I ever have before.

Here’s the thing that few people talk about: Sites, themes, or HTML in general will specify a character set that can drastically affect how the content in your page is rendered.

Continue reading

Resolving “Invalid Regular Expression Flag” in JavaScript

Thanks to modern browsers, writing cross-browser compatible JavaScript isn’t nearly as difficult as it was even just a few years ago; however, there are still times when you get cryptic error messages such as “invalid regular expression flag.”

Just as Jamie Zawinski said:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.

It’s funny because it’s true, right? But we still have regular expressions, they’re still powerful, and we still use them.

Unfortunately, there are still times in which they can plague us when working with JavaScript, string replacement, and modern web browsers.

Continue reading

How To Easily Filter Names in jQuery

If you're an advanced developer or just want the TL;DR version of this, skip to the code.

One of the more common UI design patterns is to render a table of data that includes rows that include people’s names, various information about them, and so on.

Usually, there are some type of control elements that allow you to filter the data by some type of criteria. Obviously, this is especially useful with large datasets where you don’t want to page through pages of data or scroll for a significantly long length of time.

Though there are a variety of ways to filter data – especially if you want to do so through the use of different values – one way that’s most common is to filter data by a person’s name.

If the data set is really large, this is often something that’s best left to process on the server side; however, if the data set is modest, it’s really easy to filter names in jQuery.

Continue reading

Quick Tip: Looping Through an Array with jQuery

When it comes to writing jQuery-based JavaScript, there are generally two camps of people:

  • Those who believe that you should intermingle jQuery with vanilla JavaScript for when you need it
  • Those who believe that if you’re importing jQuery, then you should use it as much as possible

Both camps have their own sets of arguments neither of which I’m looking to explore in this particular post; however, one of the features that’s all too common is having to loop through a vanilla array using JavaScript.

The two main ways that you can do about doing this are to use a standard for, while, or do loop or use jQuery’s iterator.

If you fall into the former camp, but are looking to use an iterator, here’s how you can begin looping through an array with jQuery.

Continue reading

JavaScript Screencasts From Bocoup

Aside from working with WordPress, I’m also a big fan of JavaScript and have been trying to slowly include more content about the language.

Generally speaking, I think JavaScript is an important language to learn because it’s a core component of WordPress for both plugins and themes, and for public-facing code as well as the administration area of JavaScript.

Despite the fact that WordPress uses jQuery, I think that it’s always important to explore and understand the core language, too.  Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑