- i only speak liquid
- Posts
- "i only speak liquid" #34: Section Index
"i only speak liquid" #34: Section Index
Written by Billy (a Storetasker Expert)
Hey all 👋!
Welcome to 'i_only_speak_liquid' by Storetasker, where active Shopify developers like me (Billy) share the learnings we face daily. This is my 6th edition of ‘i_only_speak_liquid’. Enjoy!
What I’ve been thinking about:
On the 18th September I saw an update on Shopify’s developer changelogs that I have been looking forward to for a very long time. As part of a performance update, Shopify have created the new index property which can be used to return the position of a section within it’s location.
If you are using the image_tag filter, lazyloading will now automatically be applied for any section after the first three. This means that you won’t have to update any of the code and your clients will be benefiting from this update already.
However, if you need more control, Shopify also have you covered. You can now use section.index and the 0-based index version section.index0 to return the position within the location.
This position number can then be used within your code to add conditions which will help benefit performance. For example, if you wanted an image to either be loaded lazily or eagerly.
Another solution that I’ve recently used in a project and really works well with the concept of sections everywhere, is using the section.index to determine whether the section heading should be a h1 tag or an alternative HTML tag. Previously, I would have to create a section setting that allows the client to choose, but often clients may not be aware of which type of tag they need to actually choose or this can simply get missed.
Shopify have released a full blog post about this update and you read more about it here.
3 links you can’t miss:
World’s shortest UI/UX design course: I’m a huge fan of the Juxtopposed YouTube channel and really enjoyed their recent video that breaks down UI/UX in a very quick and informative video
Jhey Tompkins: I’m always amazed when I see the awesomes things that developers are able to achieve with CSS. Jhey’s Twitter account is a goldmine of amazing CSS tips and demos, he is definitely someone worth following and learning from.
Shopify Theme File Search: We all hate it when we have to edit code within Shopify’s built-in code editor, but this is definitely a game changing Chrome Extension that makes the process a lot easier. It injects a search bar into the code editor that allows you to search for specific pieces of code and even Regex
One app I like:
If you read my previous post about enrichiching your navigation, you’ll know that I love the Shopify app Mechanic and the features it provides. I recently found another great app made by the same team and it allows you to lock parts of your site unless the customer meets the specific requirements.
For example you can hide a range of different parts of your site, such as products, collections, prices or even variants. These can then be shown for customers based on their tags, location or even specific passcodes.
I have built similar features many times for clients using custom JavaScript but this app is definitely a nice alternative and provides more features out of the box. It also developer friendly with its Liquid and API.
The app also has the new Built for Shopify tag so you know that it is built very well and meets Shopify’s highest quality standards.
One learning as a freelancer:
One thing I’ve recently been doing to try to manage my time more effectively is time blocking, whilst I know this is a topic that is discussed all across the internet, I was yet to really dedicate myself to it and see if I would benefit from it. Over the short time I have been trying it out, I have definitely seen some benefits.
I’ve been able to create a better balance between focus periods of work and having breaks which give me a chance to refresh. Time blocking has also mean that I can juggle the many clients and projects I do a lot more effectively. Sometimes it can be hard knowing when you need to switch to a different task but having this written down and specific time available has made it a lot easier.
Billy (linkedin)