Compare commits

..

3 commits

Author SHA1 Message Date
1972ecf043 Use async instead of defer for analytics script
We had this issue on Impress 2020 and I fixed it over there too. I guess
it went less noticed here on Classic, because it's a more
progressively-enhanced site in general (and this failure case is an
interesting argument for that architecture! lol).

On Impress 2020, I wasn't sure if the "waits for the document to load"
behavior of the `defer` attribute was necessary to the script, so I
chose to keep `defer` but move it _after_ the other scripts.

This time, I dug in a bit more, and found a Plausible author saying
that the choice was kinda arbitrary; and another person who had the
same issue as me, who said they switched to `async` and it worked well.
So, that's what we're doing now, too!

https://github.com/plausible/analytics/discussions/1907#discussioncomment-2754499
2024-08-31 12:15:27 -07:00
30e757b050 Add x86_64 versions of some of the cached gems
Two workstations with different chipsets, wowie!
2024-08-31 12:08:14 -07:00
af8dd42830 Add better support for hashed pet names
Closes #2, after making some tweaks to the PR to fit how JS templating
works here. Thanks @dice!!

I had to move `petThumbnailUrl` out of the closure, because this script
does a cute thing of having separate variable scopes for the separate
areas of the page—but this is used by two of them. Arguably it could
make sense to like, put this all in one larger shared IIFE closure that
wraps both of them, to preserve some of this code's intention of
avoiding adding to the global namespace on this page, but like.
*It's fine.*

Co-Authored-By: Steve C <diceroll123@gmail.com>
2024-08-31 12:07:52 -07:00
5 changed files with 12 additions and 7 deletions

View file

@ -1,5 +1,14 @@
var DEBUG = document.location.search.substr(0, 6) == "?debug"; var DEBUG = document.location.search.substr(0, 6) == "?debug";
function petThumbnailUrl(pet_name) {
// if first character is "@", use the hash url
if (pet_name[0] == "@") {
return "https://pets.neopets.com/cp/" + pet_name.substr(1) + "/1/1.png";
}
return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png";
}
/* Needed items form */ /* Needed items form */
(function () { (function () {
var UI = {}; var UI = {};
@ -65,10 +74,6 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug";
loadItems(data.query); loadItems(data.query);
} }
function petThumbnailUrl(pet_name) {
return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png";
}
/* Items */ /* Items */
function loadItems(query) { function loadItems(query) {
@ -127,7 +132,7 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug";
function Pet(name) { function Pet(name) {
var el = $("#bulk-pets-submission-template") var el = $("#bulk-pets-submission-template")
.tmpl({ pet_name: name }) .tmpl({ pet_name: name, pet_thumbnail: petThumbnailUrl(name) })
.appendTo(queue_el); .appendTo(queue_el);
this.load = function () { this.load = function () {

View file

@ -1,2 +1,2 @@
<%= javascript_include_tag 'https://analytics.openneo.net/js/script.js', <%= javascript_include_tag 'https://analytics.openneo.net/js/script.js',
defer: true, 'data-domain': 'impress.openneo.net' %> async: true, 'data-domain': 'impress.openneo.net' %>

View file

@ -68,7 +68,7 @@
%script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'} %script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'}
%li.waiting %li.waiting
%img{:src => 'https://pets.neopets.com/cpn/${pet_name}/1/1.png'} %img{:src => '${pet_thumbnail}'}
%span.name ${pet_name} %span.name ${pet_name}
%span.waiting-message= t '.bulk_pets.waiting' %span.waiting-message= t '.bulk_pets.waiting'
%span.loading-message= t '.bulk_pets.loading' %span.loading-message= t '.bulk_pets.loading'

Binary file not shown.

Binary file not shown.