I use JavaScript modules to organize my JS code. I use Rollup.js to package and minify these for distribution to reduce HTTP requests and transfer size, and to provide support for older browsers. So in development I'm using the modules directly and in production I'm using the built files. I was looking for a good way to have some extra code in for development purposes, but removing it for production. This could be used for a lot of things, including testing some code that runs on certain dates for dates other than the current one. I didn't find a way to do this built in to Rollup, but there is an official plugin called Strip that allows removing specific labelled statements.
Continue reading post "Rollup Strip plugin for dev code"js posts
I have finally released my website snow script as its own repo, snow.js. Continue reading post "#4766"
Project: Website theme switcher
I finally made a theme switcher for my website. Ever since I saw the CSS Zen Garden, I loved the idea of using the same markup with completely different appearances. This led to a desire to have multiple themes and an ability to switch them on my own site. Early on I didn't have the ability, and later I didn't have the energy or time, or decide on the way I wanted to do it. There are performance and complexity considerations, as well as needing to make decent themes other than the default one. My eventual desire to have a static-friendly site complicated the performance aspect as well.
Some browsers have a built in way to change to alternate stylesheets, but they stupidly download all of them even when they're not being used. I'm not doing that. So JS or a server-side cookie solution are needed, and the latter won't work for static sites. I try to minimize the JS on my site and didn't want something heavy or complex, especially if it were loading before page render.
Recently, I had the energy and decided on a simple, lightweight JS way to do it. I decided to start it even without real alternative themes. Continue reading post "Project: Website theme switcher"
I don't use npm often. When I do, I tend to be reminded of annoyances in using …
Continue reading post "#4703"Got a smartwatch: Bangle.js 2
I bought a Bangle.js 2 smartwatch from Adafruit. I haven't ever owned or played with a smartwatch, and haven't even worn a dumb watch in 15 years or more. But I got to thinking that I look at my phone a lot for time and notifications, and this could reduce phone use and simplify that behavior at the same time. An e-paper screen could make it less like looking at a mini phone on my wrist. It also could do some other things like step counting, sleep monitoring, and heart rate monitoring that might be useful, and timers, alarms, and stopwatch so I don't need to reach for my phone for those either. The Bangle is open source, lightweight, and seems feature filled enough to fit what I'm going for, cheap enough ($89) to not worry too much if I want more later.
Continue reading post "Got a smartwatch: Bangle.js 2"JS: Replace page text
For this year's April Fools Day, I decided I wanted to replace some text in the content of my site's pages to something funny, weird, or confusing. Since I'm moving toward a static site, I wanted to do this client side, which meant replacing text with JavaScript. This would be simple with innerHTML, but that completely replaces the DOM with a new DOM, possibly causing usability and performance issues, and could replace text in URLs, breaking them. Probably a better way is to loop through all nodes on the page, looking for text nodes, and replace text in each of those. So I did this, and it worked nicely. Thought I'd share.
Ideas: Cascading Behavior Sheets, a declarative alternative to JS
I have had the idea for some time that the web ought to have a declarative format to define behavior on elements like it does for styles (CSS). It would be an alternative to JavaScript (JS) that would be as robust as CSS, simplifying adding and defining common behaviors. There are a lot of things sites do frequently that can take a fair amount of work for a new person to implement, as well as require a payload sent over the wire. For people who don't need complications beyond standard, this could be provided by the browser with some configuration in a simple sheet. I think there should be a Cascading Behavior Sheet (CBS) standard for the web.
Potential advantages:
- robust forward and backward compatibility like CSS
- simpler, easier to learn format than JS
- little to write or think about for common functionality
- little to send over wire for common functionality
- more performant native implementation possible
- declarative
- familiar syntax to CSS devs
- simple to connect behavior broadly to chosen selectors
- cascade,
@media,@support, etc to limit which and when behaviors apply - automatic handling of attaching and removing behaviors when they apply / don't, including new DOM elements
- maintain separation of concerns that keeping JS and CSS separate provides
I found myself needing to get the path to the current script and its directory i…
Continue reading post "#3399"The installation of a new version of nodejs via MacPorts took nearly two hours. Continue reading post "#3312"
I guess npm doesn't find a version of a package that matches the current environment when doing npm install whatever.
Continue reading post "#3310"
GiveCamp 2018: Final day and end
GiveCamp is done. It was a success. We finished the chat app for Rubber City Theatre that will be used in live performances starting in June. Continue reading post "GiveCamp 2018: Final day and end"
GiveCamp 2018: Day one
Day one of GiveCamp comes to a close. This year I'm working on a project for Rubber City Theatre. Continue reading post "GiveCamp 2018: Day one"
Went to a refresh cleveland event tonight, ReactJS: A hands on introduction. We…
Continue reading post "#943"The Happs
For a while now I've been trying to write posts that draw people, such as solutions to specific problems or things that might be called articles. I think I've focused on these types of writings because parts of me want to be bring myself more prominently into the larger web community, help others, get some praise or critique for my work, and perhaps get offered a high paying job from some bigger web firm. I think I got a bit heady when I started getting above 50 visitors a day, peaking at 98. But that flow has dried up and I'm back down to less than 20.
I do like writing those types of posts sometimes, and I'm not going to stop, but I think I'm going to write a lot more smaller and less focused posts that are more generally about anything on my mind. I think I shall call the posts "The Happs" so I don't have to think of a title and to emphasize their lack of a specific topic. The article type posts really take a long time and some research to compose, and I don't have a lot of free time for them. It is often so long between when I do whatever is the impetus for them and when I write them that I've forgotten a lot of the details. I think "The Happs" will get me writing more often and allow me to put out snippets of what might later go into more thorough articles.
So, what has been happening with me lately?
Continue reading post "The Happs"