When I loop through a foreach, I print out a couple of links and an image in each div. I tried applying trim() to the text that’s being echoed out but the white space won’t go away. I looked at the corresponding fields in the database table and there isn’t too much white space there so it seems to be coming from my code.
If we could see your code, we might have some idea of what’s happening. Seeing the HTML it’s generating, highlighting exactly what whitespace you don’t want to be there, would give us even more idea. As it stands, we can only agree that there’s probably something wrong with your code.
I was able to get rid of the whitespace by simply removing the line breaks that were inside my php code. However, the page still loads slowly. I am using font awesome for just the hamburger icon. I could make my own CSS icon and get rid of the link to font awesome. That might speed it up a little.
Sorry, I missed the bit in the subject line where you said the site was loading slowly. Whitespace is, as you’ve found, unlikely to be the cause of that.
You should check things like the network tab of developer tools in your browser to see how long the various things that are being loaded by your page take. Figure out specifically which thing is slow, then focus on that. Otherwise, you’re just making guesses and it’s going to be a very slow debugging process.
You could also copy the HTML that’s generated from your page, put it in a static HTML page in the webroot, and see if that loads quickly. If so, then it’s something about your code or database that’s slow. If you enable SQL query logging, you can look at exactly what queries are being run, and see if one of those is very slow. Maybe you’re going a bad join or need to add an index. Maybe you’re returning thousands of lines rows of results and then doing some post-processing to eliminate most of them, instead of building that into the query.
I moved this to a new topic.