Older Tech In The Browser Stack<\/h1>\nBryan Rasmussen<\/address>\n 2025-11-13T08:00:00+00:00
\n 2025-11-13T20:32:27+00:00
\n <\/header>\n
I\u2019ve been in front-end development long enough to see a trend over the years: younger developers working with a new paradigm of programming without understanding the historical context of it.<\/p>\n
It is, of course, perfectly understandable to not<\/em> know something. The web is a very big place with a diverse set of skills and specialties, and we don\u2019t always know what we don\u2019t know. Learning in this field is an ongoing journey rather than something that happens once and ends.<\/p>\nCase in point: Someone on my team asked if it was possible to tell if users navigate away from a particular tab in the UI. I pointed out JavaScript\u2019s beforeunload<\/code> event<\/a>. But those who have tackled this before know this is possible because they have been hit with alerts about unsaved data on other sites, for which beforeunload<\/code> is a typical use case. I also pointed out the pageHide<\/code><\/a> and visibilityChange<\/code><\/a> events to my colleague for good measure.<\/p>\nHow did I know about that? Because it came up in another project, not because I studied up on it when initially learning JavaScript.<\/p>\n
The fact is that modern front-end frameworks are standing on the shoulders of the technology giants that preceded them. They abstract development practices, often for a better developer experience that reduces, or even eliminates, the need to know or touch what have traditionally been essential front-end concepts everyone probably ought to know.<\/p>\n
Consider the CSS Object Model (CSSOM)<\/a>. You might expect that anyone working in CSS and JavaScript has a bunch of hands-on CSSOM experience, but that\u2019s not always going to be the case.<\/p>\nThere was a React project for an e-commerce site I worked on where we needed to load a stylesheet for the currently selected payment provider. The problem was that the stylesheet was loading on every page when it was only really needed on a specific page. The developer tasked with making this happen hadn\u2019t ever loaded a stylesheet dynamically. Again, this is totally understandable when React abstracts away the traditional approach you might have reached for.<\/p>\n
The CSSOM is likely not something you need in your everyday work. But it is likely you will need to interact with it at some point, even in a one-off instance.<\/p>\n
These experiences inspired me to write this article. There are many existing web features and technologies in the wild that you may never touch directly in your day-to-day work. Perhaps you\u2019re fairly new to web development and are simply unaware of them because you\u2019re steeped in the abstraction of a specific framework that doesn\u2019t require you to know it deeply, or even at all.<\/p>\n
I\u2019m speaking specifically about XML<\/a>, which many of us know is an ancient language not totally dissimilar from HTML.<\/p>\nI\u2019m bringing this up because of recent WHATWG discussions suggesting<\/a> that a significant chunk of the XML stack known as XSLT<\/a> programming should be removed from browsers. This is exactly the sort of older, existing technology we\u2019ve had for years that could be used for something as practical as the CSSOM situation my team was in.<\/p>\nHave you worked with XSLT before? Let\u2019s see if we lean heavily into this older technology and leverage its features outside the context of XML to tackle real-world problems today.<\/p>\n
XPath: The Central API<\/h2>\n
The most important XML technology that is perhaps the most useful outside of a straight XML perspective is XPath<\/strong>, a query language that allows you to find any node or attribute in a markup tree with one root element. I have a personal affection for XSLT, but that also relies on XPath, and personal affection must be put aside in ranking importance.<\/p>\nThe argument for removing XSLT does not make any mention of XPath, so I suppose it is still allowed. That\u2019s good because XPath is the central and most important API in this suite of technologies, especially when trying to find something to use outside normal XML usage. It is important because, while CSS selectors can be used to find most of the elements in your page, they cannot find them all. Furthermore, CSS selectors cannot be used to find an element based on its current position in the DOM.<\/p>\n
XPath can.<\/p>\n
Now, some of you reading this might know XPath, and some might not. XPath is a pretty big area of technology, and I can\u2019t really teach all the basics and also show you cool things to do with it in a single article like this. I actually tried writing that article, but the average Smashing Magazine publication doesn\u2019t go over 5,000 words. I was already at more than 2,000 words while only halfway through the basics.<\/p>\n
So, I\u2019m going to start doing cool stuff with XPath and give you some links that you can use for the basics if you find this stuff interesting.<\/p>\n
Combining XPath & CSS<\/h2>\n
XPath can do lots of things that CSS selectors can\u2019t when querying elements. But CSS selectors can also do a few things that XPath can\u2019t, namely, query elements by class name.<\/p>\n
\n 2025-11-13T20:32:27+00:00
\n <\/header>\n
Case in point: Someone on my team asked if it was possible to tell if users navigate away from a particular tab in the UI. I pointed out JavaScript\u2019s How did I know about that? Because it came up in another project, not because I studied up on it when initially learning JavaScript.<\/p>\n The fact is that modern front-end frameworks are standing on the shoulders of the technology giants that preceded them. They abstract development practices, often for a better developer experience that reduces, or even eliminates, the need to know or touch what have traditionally been essential front-end concepts everyone probably ought to know.<\/p>\n Consider the CSS Object Model (CSSOM)<\/a>. You might expect that anyone working in CSS and JavaScript has a bunch of hands-on CSSOM experience, but that\u2019s not always going to be the case.<\/p>\n There was a React project for an e-commerce site I worked on where we needed to load a stylesheet for the currently selected payment provider. The problem was that the stylesheet was loading on every page when it was only really needed on a specific page. The developer tasked with making this happen hadn\u2019t ever loaded a stylesheet dynamically. Again, this is totally understandable when React abstracts away the traditional approach you might have reached for.<\/p>\n The CSSOM is likely not something you need in your everyday work. But it is likely you will need to interact with it at some point, even in a one-off instance.<\/p>\n These experiences inspired me to write this article. There are many existing web features and technologies in the wild that you may never touch directly in your day-to-day work. Perhaps you\u2019re fairly new to web development and are simply unaware of them because you\u2019re steeped in the abstraction of a specific framework that doesn\u2019t require you to know it deeply, or even at all.<\/p>\n I\u2019m speaking specifically about XML<\/a>, which many of us know is an ancient language not totally dissimilar from HTML.<\/p>\n I\u2019m bringing this up because of recent WHATWG discussions suggesting<\/a> that a significant chunk of the XML stack known as XSLT<\/a> programming should be removed from browsers. This is exactly the sort of older, existing technology we\u2019ve had for years that could be used for something as practical as the CSSOM situation my team was in.<\/p>\n Have you worked with XSLT before? Let\u2019s see if we lean heavily into this older technology and leverage its features outside the context of XML to tackle real-world problems today.<\/p>\n The most important XML technology that is perhaps the most useful outside of a straight XML perspective is XPath<\/strong>, a query language that allows you to find any node or attribute in a markup tree with one root element. I have a personal affection for XSLT, but that also relies on XPath, and personal affection must be put aside in ranking importance.<\/p>\n The argument for removing XSLT does not make any mention of XPath, so I suppose it is still allowed. That\u2019s good because XPath is the central and most important API in this suite of technologies, especially when trying to find something to use outside normal XML usage. It is important because, while CSS selectors can be used to find most of the elements in your page, they cannot find them all. Furthermore, CSS selectors cannot be used to find an element based on its current position in the DOM.<\/p>\n XPath can.<\/p>\n Now, some of you reading this might know XPath, and some might not. XPath is a pretty big area of technology, and I can\u2019t really teach all the basics and also show you cool things to do with it in a single article like this. I actually tried writing that article, but the average Smashing Magazine publication doesn\u2019t go over 5,000 words. I was already at more than 2,000 words while only halfway through the basics.<\/p>\n So, I\u2019m going to start doing cool stuff with XPath and give you some links that you can use for the basics if you find this stuff interesting.<\/p>\n XPath can do lots of things that CSS selectors can\u2019t when querying elements. But CSS selectors can also do a few things that XPath can\u2019t, namely, query elements by class name.<\/p>\nbeforeunload<\/code> event<\/a>. But those who have tackled this before know this is possible because they have been hit with alerts about unsaved data on other sites, for which beforeunload<\/code> is a typical use case. I also pointed out the pageHide<\/code><\/a> and visibilityChange<\/code><\/a> events to my colleague for good measure.<\/p>\nXPath: The Central API<\/h2>\n
Combining XPath & CSS<\/h2>\n