Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

What is the Best Practise for Loading Text Content to a Webpage

  • 12-12-2015 2:53pm
    #1
    Registered Users, Registered Users 2 Posts: 266 ✭✭


    I would like to know is there any convention or best practise for loading text content into a web page. I know there’s the backend method of Ajax, json and xml. But is this necessary if all I want to do is load content from an external txt or html file into divs on my index file. Although what I'm using is static content it doesn't seem very elegant to have it within the index.html file and it is for my own personal profile site.
    Currently I’m using an external txt file and loading it with...
    $(document).ready(function(){        
                $("#div1").load("file.txt");
        });  
    

    Where div1 is the id selector on the div. But with the txt file I’m having encoding issues with apostrophes (i.e. instead a triangle with a question mark appears on the web page.).
    But I’m wondering as to what is the best and most common practice for doing this?
    Is it possible to have all required text in a txt or html file with sections of text being linked or loaded into different divs?
    I have seen what I am looking for implemented with angular and json but I’m not using angular here.
    I am very new to web development so with this in mind should I use AJAX?

    Any help is much appreciated.


Comments

  • Registered Users, Registered Users 2 Posts: 403 ✭✭counterpointaud


    My advice is to check out static site generators like Jekyll and Roots, and use Markdown instead of plain text. This combination solves the exact problem you describe, and you won't have the SEO issues associated with loading content dynamically.


  • Registered Users, Registered Users 2 Posts: 10,902 ✭✭✭✭28064212


    "Best practise" is including it in the html file. You definitely don't want to load it using javascript, what if the user has javascript turned off?

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Closed Accounts Posts: 9,700 ✭✭✭tricky D


    Once upon a time... ssi (server side includes). Haven't seen or heard of being them used in a while and they're available on my hosting.


  • Registered Users, Registered Users 2 Posts: 266 ✭✭Gerb68


    The thing is that I want this to be a personal profile website made with bootstrap that will say a lot about my current web development abilities and showcase what I know. I also plan on making the code available through my GitHub account. So I was planning on using an external html file or even loading a JSON file. I'm just worried if this might seem like overkill or that it will lead to webpage loading delays and therefore be counter productive.


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    Its overkill. Just put the the text in the file.


  • Advertisement
Advertisement